package com.dingwen.treasure.business.service.impl;

import com.dingwen.treasure.business.service.TestBarService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 进度条任务测试服务
 *
 * @author dingwen
 * @date 2022/12/08
 */
@Service
@Slf4j
public class TestBarServiceImpl implements TestBarService {
    @Override
    public List<Integer> getTaskOriginalData(Integer param) {
        List<Integer> integers = new ArrayList<>(param);
        for (int i = 1; i <= param; i++) {
            integers.add(i);
        }
        return integers;
    }

    @Override
    public Boolean executeTask(Integer param, Integer num) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.info("多线程进度条任务执行，当前线程:{}",Thread.currentThread().getName());
        return param * num % 2 == 0;
    }

    @Override
    public void after() {
        log.info("多线程进度条任务后置处理方法执行...");
    }
}
